﻿using CacheTestApp.Resources;
using CacheTestApp.ViewModels;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using NCache;
using NCommonLib.Thread;
using System;
using System.Windows;

namespace CacheTestApp
{
    public partial class MainPage : PhoneApplicationPage
    {
        private MainViewModel _mainViewModel;

        public MainPage()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            _mainViewModel = this.DataContext as MainViewModel;
            _mainViewModel.OnNavigateTo(this, e);
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            StorageHelper.ClearAll(CacheEngine.CacheFolder);
        }

        private void CancelBtn_Click(object sender, EventArgs e)
        {
            CancellationTokenFactory.Instance.GetCancelToken("page1").Cancel();
        }
    }
}